﻿using TjZheng.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using TjZheng.Framework;

namespace TjZheng.EasyUI
{
    public static partial class QueryExtension
    {
        public static MvcHtmlString QueryComboBox(this HtmlHelper htmlHelper, string title, string name, QueryMethod objQueryMethod, QueryDataType objQueryDataType, List<SelectListItem> selectList, object htmlAttributes = null, SelectListItem optionLabel = null)
        {
            if (selectList.IsNull())
            {
                return MvcHtmlString.Create("<!--未设置下拉选项-->");
            }
            IList<SelectListItem> objProvider = selectList.ToList();
            if (optionLabel == null)
            {
                optionLabel = new SelectListItem { Text = "==全部==" };
            }
            objProvider.Insert(0, optionLabel);
            QueryDropDownList objQueryDropDownList = new QueryDropDownList(name, QueryComboType.ComboBox, objProvider)
            {
                QueryTitle = title,
                QueryMethod = objQueryMethod,
                QueryDataType = objQueryDataType,
                HtmlAttributes = htmlAttributes.CreateValueDictionary()
            };
            return htmlHelper.CreateQueryInfo(objQueryDropDownList);
        }
        public static MvcHtmlString QueryComboBox(this HtmlHelper htmlHelper, string title, string name, List<SelectListItem> selectList, object htmlAttributes = null, SelectListItem optionLabel = null)
        {
            return htmlHelper.QueryComboBox(title, name, QueryMethod.Equal, QueryDataType.Int, selectList, htmlAttributes, optionLabel);
        }
    }
}
